package com.stopboot.code.generator.modle;

import lombok.Data;

import java.io.Serializable;

/**
 * @description:
 * @author: Lianyutao
 * @create: 2019-10-16 15:34
 * @version:
 **/

@Data
public class TableColumnBo implements Serializable {
    private String ordinalPosition;
    private String columnName;
    private String dataType;
    private String nullable;
    private String columnComment;
    private String columnKey;
    private String columnType;
    private String javaType;
    private String javaColumnName;

    private Integer length;


    /**
     * 数字精度
     */
    private Long numericPrecision;

    /**
     * 数字刻度（小数点后位数）
     */
    private Long numericScale;

    /**
     * mysql手册的解释：
     * CHARACTER_MAXIMUM_LENGTH：以字符为单位的最大长度，适于二进制数据、字符数据，或者文本和图像数据。否则，返回 NULL。
     * CHARACTER_OCTET_LENGTH：以字节为单位的最大长度，适于二进制数据、字符数据，或者文本和图像数据。否则，返回 NULL。
     * CHARACTER_OCTET_LENGTH应与CHARACTER_MAXIMUM_LENGTH相同，但多字节字符集除外。
     */

    private Long characterMaximumLength;

    private Long characterOctetLength;


    /**
     * 主键，索引 通常再这个字段里
     */
    private String extra;


    /**
     * 	DATETIME_PRECISION,
     * 	CHARACTER_SET_NAME,
     * 	COLLATION_NAME ,
     */

    private String datetimePrecision;

    private String characterSetName;

    private String collationName;


    //============oracle ==================//

    //oracle专用
    private String tableName;
    private String columnId;
    private String comments;
    private String constraintType;
    private Integer dataScale;


    public void setComments(String comments) {

        if (comments != null) {
            comments = comments.replaceAll("\uff08", "");
            comments = comments.replaceAll("\n", "");
        }else{
            comments = "";
        }
        this.comments = comments;
        this.columnComment = comments;
    }

}
